/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dao;

import entities.FlMember;
import entities.FlMembergroup;
import java.io.Serializable;
import java.util.Iterator;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.TypedQuery;

/**
 *
 * @author niit
 */
public class FlMemberDao implements Serializable {

    EntityManagerFactory emf = Persistence.createEntityManagerFactory("FastLearnWebsitePU");
    EntityManager em = emf.createEntityManager();

    public boolean login(FlMember member) {
        TypedQuery<FlMember> query = em.createNamedQuery("FlMember.findByUsename", FlMember.class).setParameter("usename", member.getUsename());
        FlMember flMember = query.getSingleResult();
        if (member.getPasswd().equals(flMember.getPasswd())
                && flMember.getBlock().equals(false)) {
            FlMembergroup membergroup = new FlMembergroup(flMember.getMemberid());
            return true;
        }

        return false;
    }
}
